<template>
    <div>
        <div style="height:0.9rem"></div>
        <!-- 资讯详情 -->
        <div class="info-box">
            <div class="info-title">
                {{title}}
            </div>
            <div class="info-time-box flex flex-align-center">
                <div class="item">{{time}}</div>
                <div v-if='auther'>来源:{{auther}}</div>
            </div>
            <div class="info-cont" v-html='cont'>
                    
            </div>
        </div>
        <!-- 推荐内容 -->
        <Recommend v-if ='isShow' :recommoned='recommoned' v-on:Detailes="apiIndexDetail"></Recommend>
        <div style="height:2rem"></div>
    </div>
</template>
<script>
 import Recommend from '@/components/common/Recommend'
 import {format} from '../../public/utils'
export default {
        data () {
            return {
                title:'',
                time:'',
                auther:'',
                cont:'',
                recommoned:'',
                isShow:false
            }
        },
        computed: {
            menu(){
                return this.$store.getters.getTitle;
            }
        },
        components:{
            Recommend
        },

        mounted () {
            if(this.menu == "活动详情"){
                this.isShow = false;
                this.apiActivityDetail();
            }else if(this.menu == "最新资讯"){
                this.isShow = true;
                this.apiIndustryContent();
            }else if(this.menu == "推荐内容" || this.menu == "健康养生"){
                let id = this.$route.params.id;
                this.isShow = false;
                this.apiIndexDetail(id);
            }else{
                this.isShow = true;
                this.apiDynamicDetail();
            }
        },

        methods: {
            // 根据活动id,获取活动详情
            async apiActivityDetail(){
                let id = this.$route.params.id;
                let {data} = await this.https.get(this.api.apiActivityDetail,{id,id});
                this.title = data.title;
                this.time = format(data.create_time);
                this.cont = data.content;
                this.auther = data.auther;
            },

            // 最新资讯详情
            async apiIndustryContent(){
                let id = this.$route.params.id;
                let {data} = await this.https.get(this.api.apiIndustryContent,{id,id});
                this.title = data.content.title;
                this.time = format(data.content.create_time);
                this.cont = data.content.content;
                this.auther = data.content.auther;
                this.recommoned = data.recommoned;
            },

            // 推荐内容详情
            async apiIndexDetail(id){
                this.isShow = false;
                let {data} = await this.https.get(this.api.apiIndexDetail,{id,id});
                this.title = data.title;
                this.time = format(data.create_time);
                this.cont = data.content;
                this.auther = data.auther;
            },

            async apiDynamicDetail(){
                let id = this.$route.params.id;
                let {data} = await this.https.get(this.api.apiDynamicDetail,{id,id});
                this.title = data.content.title;
                this.time = format(data.content.create_time);
                this.cont = data.content.content;
                this.auther = data.auther;
                this.recommoned = data.recommoned;
            },


        }
}
</script>
<style lang="less" scoped>
@import url(../../assets/css/industryinfo/viewdetails.less);
</style>


